package one.stand.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import one.stand.aop.ApiController;
import one.stand.aop.CompanyVerification;
import one.stand.model.ResultModel;
import one.stand.request.*;
import one.stand.response.BusinessCardResponse;
import one.stand.response.CompanyResponse;
import one.stand.response.SunCodeResponse;
import org.springframework.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("userApi/businessCard")
@Api(description = "名片系列",tags="名片系列")
public class BusinessCardController extends BaseController {

    @ApiOperation(value = "得到登录人的公司id")
    @ApiController(isLogin = true,paramClass =CompanyRequest.class)
    @PostMapping("getCompanyId")
    public ResultModel<CompanyResponse> getCompanyId(@RequestAttribute CompanyRequest request) {
        return crmFegin.getCompanyId(request);
    }

    @PostMapping("seeDetail")
    @ApiOperation(value = "查看名片列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "姓名", paramType = "String"),
    })
    @ApiController(isLogin = true,paramClass = BusinessCardRequest.class)
    public ResultModel<List<BusinessCardResponse>> seeDetail(@RequestAttribute BusinessCardRequest request) {
        return userFegin.seeDetail(request);
    }


    @PostMapping("findDefaultBusinessCards")
    @ApiOperation(value = "查看默认名片列表")
    @ApiController(paramClass =BusinessCardRequest.class)
    public ResultModel<List<BusinessCardResponse>> findDefaultBusinessCards(@RequestAttribute BusinessCardRequest request) {
        return userFegin.findDefaultBusinessCards(request);
    }



    @PostMapping("createCard")
    @ApiOperation(value = "创建名片")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "style", value = "名片样式", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "companyId", value = "公司id",required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "name", value = "姓名",required = true, paramType = "String"),
            @ApiImplicitParam(name = "phone", value = "电话",required = true, paramType = "String"),
            @ApiImplicitParam(name = "logo", value = "头像url", paramType = "String"),
            @ApiImplicitParam(name = "personalWx", value = "个人微信",required = true, paramType = "String"),
            @ApiImplicitParam(name = "companyWx", value = "公司微信", paramType = "String"),
            @ApiImplicitParam(name = "photo", value = "个人照片集合（1.png,2.png,3.png）", paramType = "String"),
            @ApiImplicitParam(name = "position", value = "职位", paramType = "String"),
            @ApiImplicitParam(name = "soundRecording", value = "个人录音", paramType = "String"),
            @ApiImplicitParam(name = "soundTime", value = "录音时长", paramType = "Integer"),
            @ApiImplicitParam(name = "email", value = "邮箱", paramType = "String"),
            @ApiImplicitParam(name = "briefIntroduction", value = "个人简介", paramType = "String"),
    })
    @ApiController(isLogin = true,paramClass = BusinessCardRequest.class)
    public ResultModel<Boolean> createCard(@RequestAttribute BusinessCardRequest request) {
        return userFegin.createCard(request);
    }

    @PostMapping("updateCard")
    @ApiOperation(value = "修改名片")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "名片id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "style", value = "名片样式", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "companyId", value = "公司id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "name", value = "姓名", paramType = "String"),
            @ApiImplicitParam(name = "phone", value = "电话", paramType = "String"),
            @ApiImplicitParam(name = "logo", value = "头像url", paramType = "String"),
            @ApiImplicitParam(name = "personalWx", value = "个人微信", paramType = "String"),
            @ApiImplicitParam(name = "companyWx", value = "公司微信", paramType = "String"),
            @ApiImplicitParam(name = "photo", value = "个人照片集合（1.png,2.png,3.png）", paramType = "String"),
            @ApiImplicitParam(name = "position", value = "职位", paramType = "String"),
            @ApiImplicitParam(name = "soundRecording", value = "个人录音", paramType = "String"),
            @ApiImplicitParam(name = "soundTime", value = "录音时长", paramType = "Integer"),
            @ApiImplicitParam(name = "email", value = "邮箱", paramType = "String"),
            @ApiImplicitParam(name = "briefIntroduction", value = "个人简介", paramType = "String"),
    })
    @ApiController(isLogin = true,paramClass = BusinessCardRequest.class)
    public ResultModel<Boolean> updateCard(@RequestAttribute BusinessCardRequest request) {
        return userFegin.updateCard(request);
    }

    @PostMapping("cardDetails")
    @ApiOperation(value = "名片详情")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "名片id", required = true, paramType = "Integer"),
            @ApiImplicitParam(name = "refresh", value = "刷新进入传1", paramType = "String"),
    })
    @ApiController(isLogin = true,paramClass = BusinessCardRequest.class)
    public ResultModel<BusinessCardResponse> cardDetails(@RequestAttribute BusinessCardRequest request) {
        return userFegin.cardDetails(request);
    }

    @PostMapping("findBusinessCardDetail")
    @ApiOperation(value = "名片详情-不登录也可以获取")
    @ApiImplicitParams({
                    @ApiImplicitParam(name = "cardId", value = "名片id", required = true, paramType = "Integer"),
                    @ApiImplicitParam(name = "refresh", value = "刷新进入传1", paramType = "String"),
    })
    @ApiController(paramClass = BusinessCardRequest.class)
    public ResultModel<BusinessCardResponse> findBusinessCardDetail(@RequestAttribute BusinessCardRequest request) {
        return userFegin.findBusinessCardDetail(request);
    }



    @PostMapping("isTop")
    @ApiOperation(value = "名片置顶")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "recordId", value = "名片记录id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass = SeeRecordRequest.class)
    public ResultModel<Boolean> isTop(@RequestAttribute SeeRecordRequest request) {
        return userFegin.isTop(request);
    }

    @PostMapping("getUserCard")
    @ApiController(isLogin = true,isParam = false)
    @ApiOperation(value = "查询用户自己的名片")
    public ResultModel<BusinessCardResponse> getUserCard(BusinessCardRequest request,@RequestAttribute TokenRequest tokenRequest) {
        BeanUtils.copyProperties(tokenRequest,request);
        return userFegin.getUserCard(request);
    }

    @PostMapping("delSeeCard")
    @ApiController(isLogin = true,paramClass = SeeRecordRequest.class)
    @ApiOperation(value = "删除浏览记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "名片id", required = true, paramType = "Integer"),
    })
    public ResultModel delSeeCard(@RequestAttribute SeeRecordRequest request) {
        return userFegin.delSeeCard(request);
    }

    @PostMapping("doThumbs")
    @ApiController(isLogin = true,paramClass = SeeRecordRequest.class)
    @ApiOperation(value = "点赞操作")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "名片id", required = true, paramType = "Integer"),
    })
    public ResultModel doThumbs(@RequestAttribute SeeRecordRequest request) {
        return userFegin.doThumbs(request);
    }

    @PostMapping("getWxTwoCode")
    @ApiOperation(value = "得到名片二维码")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "名片id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass = BusinessCardRequest.class)
    public ResultModel getWxTwoCode(@RequestAttribute BusinessCardRequest request) {
        return crmFegin.getWxTwoCode(request);
    }

    @PostMapping("addCallsRecord")
    @ApiOperation(value = "添加通话记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "被拨打人名片id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,paramClass = CallsPhoneRecordRequest.class)
    public ResultModel addCallsRecord(@RequestAttribute CallsPhoneRecordRequest request) {
        return userFegin.addCallsRecord(request);
    }

    @PostMapping("/verifyExpired")
    @ApiOperation(value = "验证名片是否过期")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "名片id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true,card = true,paramClass = BusinessCardRequest.class)
    public ResultModel<Long> verifyExpired(@RequestAttribute BusinessCardRequest request) {
        return crmFegin.verifyExpired(request);
    }

    @PostMapping("getCardPoster")
    @ApiOperation(value = "得到名片海报")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "cardId", value = "名片id", required = true, paramType = "Integer"),
    })
    @ApiController(isLogin = true, company = true,card = true,paramClass = BusinessCardRequest.class)
    public ResultModel getCardPoster(@RequestAttribute BusinessCardRequest request) {
        return crmFegin.getCardPoster(request);
    }

    @PostMapping("getSunCode")
    @ApiOperation(value = "得到太阳码参数")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "sunCodeId", value = "id", required = true, paramType = "Integer"),
    })
    @ApiController(paramClass = SunCodeRequest.class)
    public ResultModel<SunCodeResponse> getSunCode(@RequestAttribute SunCodeRequest request) {
        return userFegin.getSunCode(request);
    }
}
